<?php
class HS2model extends BaseModel implements Model {
    function __construct() {
        parent::__construct("hs_chapters", "");
        $this->addField("chapter", Model::TYPE_VARCHAR);
        $this->addField("name_en", Model::TYPE_VARCHAR);
        $this->addField("name_hu", Model::TYPE_VARCHAR);
    }

    public function renderAlias($record) {
        $result = $record;
        return $result;
    }

    public function loadAll($condParam) {
        $result = array();
        if ($condParam) {
            $query = "SELECT * FROM hs_chapters WHERE chapter LIKE '$condParam%'";
            $res = Database::executeQuery($query);
            $result = Database::getDatafromResource($res);
        } else {
            $result = parent::loadAll("true");
        }
        return $result;
    }

    public function isAuthorized($operation, $subject = "") {
        return true;
//        if (Auth::isAdmin()) { return true; }
/*
        switch ($operation) {
            case "update" :
            case "delete" :
            case "addnew" : {
                if (Auth::canChangeDrivers()) { return true; }
            }
            case "list" : {
                if (Auth::canListDrivers()) { return true; }
            }
        }
        return false;
*/
    }

    public function modifyDatabaseInput($data) {
        $result = array();
        return $result;
    }
}

?>
